<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Swing BoxLayout</title>
	<link href="../../../../book.css" rel="stylesheet" type="text/css">
</head>

<body>
<h1>Swing BoxLayout</h1>
<table border="0" width="810" cellspacing="0" cellpadding="0">
	<tr>
		<td><b>BoxLayout</b> allows multiple components to be laid out either 
		vertically or horizontally. The components will not wrap so, for 
		example, a vertical arrangement of components will stay vertically 
		arranged when the frame is resized. Nesting multiple panels with 
		different combinations of horizontal and vertical gives an effect 
		similar to <b>GridBagLayout</b>, without the complexity. The <b>
		BoxLayout</b> manager is constructed with an axis parameter that 
		specifies the type of layout that will be done. For all directions, 
		components are arranged in the same order as they were added to the 
		container. <br>
		<br>
		<b>BoxLayout</b> attempts to arrange components at their preferred 
		widths (for horizontal layout) or heights (for vertical layout). For a 
		horizontal layout, if not all the components are the same height, <b>
		BoxLayout</b> attempts to make all the components as high as the highest 
		component. If that's not possible for a particular component, then <b>
		BoxLayout</b> aligns that component vertically, according to the 
		component's Y alignment. By default, a component has a Y alignment of 
		0.5, which means that the vertical center of the component should have 
		the same Y coordinate as the vertical centers of other components with 
		0.5 Y alignment. Similarly, for a vertical layout, <b>BoxLayout</b> 
		attempts to make all components in the column as wide as the widest 
		component. If that fails, it aligns them horizontally according to their 
		X alignments.<ul>
		<li><a href="#MainFeatures">Main Features</a></li>
		<li><a href="#GraphicalFeedback">Graphical Feedback</a></li>
	</ul>
    <p></p>
<h2><a name="MainFeatures"></a>Main Features</h2>
            <ul>
              <li>Select <b>BoxLayout</b> from the <b>Layouts</b> palette and 
				drop it on a Window or Composite</li>
            </ul>
<blockquote>
	<p>
	<img border="0" src="images/boxl_design_view.gif"></p>
</blockquote>
<ul>
				<li>Graphical feedback is provided for all drop and move 
				interactions</li>
            </ul>
<blockquote>
	<p>
	<img border="0" src="images/boxl_drop1.gif">&nbsp;
				<img border="0" src="images/boxl_move1.gif"></p>
</blockquote>
<ul>
				<li><b>Struts &amp; Springs</b> 
				palette gives easy access to struts, springs (glue), rigid 
				areas and boxes</li>
            </ul>
		<blockquote>
			<p>
      <img src="images/palette_swing_struts_springs.gif" border="0" width="153" height="195"></p>
		</blockquote>
		<ul>
				<li>Graphically show area occupied by struts and springs (glue)</li>
            </ul>
		<blockquote>
			<p>
	<img border="0" src="images/boxl_struts_springs.gif"></p>
		</blockquote>
		<ul>
				<li>Graphically resize struts and rigid areas via dragging</li>
            </ul>
		<blockquote>
			<p>
	<img border="0" src="images/boxl_strut_size1.gif">&nbsp;
	<img border="0" src="images/boxl_strut_size2.gif"></p>
		</blockquote>
		<ul>
				<li>Direct-edit (hit space bar) struts and rigid areas to resize 
				them</li>
            </ul>
		<blockquote>
			<p>
	<img border="0" src="images/boxl_strut_direct_edit.gif">&nbsp;
	<img border="0" src="images/boxl_strut_direct_edit2.gif" width="358" height="253"></p>
		</blockquote>
		<ul>
				<li>Resize struts and rigid areas using the <b>
				Property Pane</b></li>
            </ul>
		<blockquote>
			<p>
			<img border="0" src="images/boxl_properties2.gif" align="top" width="194" height="131">&nbsp;
	<img border="0" src="images/boxl_strut_size2.gif"></p>
		</blockquote>
		<ul>
				<li>Orientation can be specified using the <b>
				Property Pane</b></li>
            </ul>
<blockquote>
	<p><img border="0" src="images/boxl_properties.gif" align="top">&nbsp;
	<img border="0" src="images/boxl_axis.gif"></p>
</blockquote>
          <ul>
			<li>Widget alignment within the <b>BoxLayout</b> can be set using 
			the <b>
				Property Pane</b></li>
		</ul>
		<blockquote>
			<p><img border="0" src="images/boxl_properties3.gif" align="top"></p>
		</blockquote>
		<ul>
			<li>Note that struts and rigid areas can be used as invisible spacer 
			objects in other layouts as well</li>
		</ul>
		<blockquote>
			<p>
	<img border="0" src="images/gl_strut.gif">&nbsp;
	<img border="0" src="images/bl_strut.gif"></p>
		</blockquote>
          <p></p>
            <h2><a name="GraphicalFeedback"></a>Graphical Feedback</h2>
            <ul>
              <li>When moving a widget or adding a new widget, the current drop 
				point is highlighted in red<br>
				<br>
	<img border="0" src="images/boxl_drop1.gif">&nbsp;
	<img border="0" src="images/boxl_drop2.gif"><br>
				<img border="0" src="images/boxl_move1.gif">&nbsp;
				<img border="0" src="images/boxl_move2.gif"><br>
&nbsp;</li>
				<li>Resize struts and rigid areas by dragging or direct edit</li>
            </ul>
		<blockquote>
			<p>
	<img border="0" src="images/boxl_strut_size1.gif">&nbsp;
	<img border="0" src="images/boxl_strut_direct_edit.gif"></p>
		</blockquote>
		</td>
	</tr>
</table>
</body>
</html>